﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZeCloud.Resto55.Business;
using ZeCloud.Resto55.Business.Table;

namespace Resto55Business_WebRole
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BT_Search_Click(object sender, EventArgs e)
        {
            RestoService RestoServ = BusinessFacade.CreerFacade().GetRestoService();
            var Restos = RestoServ.RechercherRestosParVille(TB_Town.Text).OrderBy(x => x.ville);
            //ListView1.DataSource = Restos;
            //ListView1.DataBind();
            //Envoie directement sur la consultation si il n'ya qu'un seul resto de sélectionné
            if (Restos.Count() == 1)
                Response.Redirect("Consult.aspx?id="+Restos.First().uniqueId);
            DataList1.DataSource = Restos;
            DataList1.DataBind();
        }

       
    }
}
